package qky.api.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import qky.common.utils.RedisUtils;

@Service("verifyCodeService")
public class VerifyCodeService {

    @Autowired
    private RedisUtils redisUtils;

    public void sendAndCacheVerifyCode(String mobile, String verifyCode){
        if (verifyCode == null) {
            verifyCode = "666666";
        }
        //发送验证码

        //缓存到redis
        redisUtils.set(mobile+":verifyCode", verifyCode, 10*60);
    }

    public Boolean checkVerifyCode(String mobile, String verifyCode){
        String cacheKey = mobile+":verifyCode";
        return verifyCode.equals(redisUtils.get(cacheKey));
    }



}
